<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Mentra Account</title>
    <meta name="description" content="Manage your Mentra account" />
    <script>
      // Handle verified-email redirect by preserving hash fragment
      if (window.location.pathname.includes("/verified-email")) {
        // Save the hash (contains the token) and redirect to root
        const currentHash = window.location.hash;
        if (currentHash) {
          // Store hash temporarily to retrieve after redirect
          sessionStorage.setItem("auth_hash", currentHash);
          window.location.href = "/";
        }
      }

      // Check and restore hash from the verified-email flow
      document.addEventListener("DOMContentLoaded", function () {
        const savedHash = sessionStorage.getItem("auth_hash");
        if (savedHash && !window.location.hash) {
          // Clear the stored hash to prevent issues with future page loads
          sessionStorage.removeItem("auth_hash");
          // Restore the hash which triggers Supabase Auth to process it
          window.location.hash = savedHash;
        }
      });
    </script>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
  </body>
</html>
